package com.droid.smsobserverlibrary;

import android.annotation.SuppressLint;

import androidx.annotation.NonNull;

import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;

public class SmsBean implements Serializable {
    private static final long serialVersionUID = 4681317447036900239L;
    //    _id 一个自增字段，从1开始
//
//    thread_id 序号，同一发信人的id相同
//
//    address 发件人手机号码
//
//    person 联系人列表里的序号，陌生人为null
//
//    date 发件日期
//
//    protocol 协议，分为： 0 SMS_RPOTO, 1 MMS_PROTO
//
//    read 是否阅读 0未读， 1已读
//
//    status 状态 -1接收，0 complete, 64 pending, 128 failed
//
//    type ALL = 0;INBOX = 1;SENT = 2;DRAFT = 3;OUTBOX = 4;FAILED = 5; QUEUED = 6;
//
//    body 短信内容
//
//    service_center 短信服务中心号码编号。如+8613800755500
//
//    subject 短信的主题
    private String address;
    private long date;
    private String content;

    public SmsBean() {
    }

    public SmsBean(String address, long date, String content) {
        this.address = address;
        this.date = date;
        this.content = content;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public long getDate() {
        return date;
    }

    public void setDate(long date) {
        this.date = date;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    public String getDate(String format) {
        return getDateToString(date, format);
    }

    @NonNull
    @Override
    public String toString() {
        return "{\"date\": \"" + getDateToString(date, "yyyy-MM-dd HH:mm:ss") + "\"  , \"address\": \"" + address + "\" , \"content\": \"" + content + "\" }";
    }

    @SuppressLint("SimpleDateFormat")
    public String getDateToString(long milSecond, String pattern) {
        Date date = new Date(milSecond);
         SimpleDateFormat format = new SimpleDateFormat(pattern);
        return format.format(date);
    }
}
